package com.bcbim.authentication.ability.service;

import com.bcbim.authentication.ability.mapper.AbilityMaintainMapper;
import com.bcbim.authentication_interface.ability.dao.RoleAbilityDAO;
import com.bcbim.authentication_interface.ability.dto.AbilityDTO;
import com.bcbim.authentication_interface.ability.service.AbilityService;
import com.bcbim.authentication_interface.ability.vo.AbilityDetailVO;
import com.bcbim.common.sys.Code;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @program: working_platform
 * @Description:
 * @Author xuehao
 * @Date 2022/02/09  15:16
 * @Version V1.0
 **/

@Service(timeout = 60 * 1000, group = "ability", version = "1.0.0")
public class AbilityServiceImpl implements AbilityService {

    @Autowired
    private AbilityMaintainMapper abilityMapper;

    /**
     * 二级菜单下拉
     *
     * @param parentId
     * @author xuehao
     * @createDate 2022/2/9 15:18
     * @retuen List<Code>
     */
    @Override
    public List<Code> pullSubMenu(String parentId, String applicationPlatform) {
        return abilityMapper.pullSubMenu(parentId, applicationPlatform);
    }

    /**
     * 一级菜单下拉
     *
     * @author xuehao
     * @createDate 2022/2/10 10:36
     * @retuen List<Code>
     */
    @Override
    public List<Code> pullParentMenu(String applicationPlatform) {
        return abilityMapper.pullParentMenu(applicationPlatform);
    }

    /**
     * 新增功能
     *
     * @param abilityDTO
     * @author xuehao
     * @createDate 2022/2/10 16:28
     * @retuen int
     */
    @Override
    public int insertAbility(AbilityDTO abilityDTO) {
        return abilityMapper.insertAbility(abilityDTO);
    }

    /**
     * 删除功能
     *
     * @param id
     * @author xuehao
     * @createDate 2022/2/10 17:38
     * @retuen int
     */
    @Override
    public int deleteAbility(String id) {
        return abilityMapper.deleteAbility(id);
    }

    /**
     * 根据用户查角色id
     *
     * @param userId
     * @author xuehao
     * @createDate 2022/2/11 14:13
     * @retuen String
     */
    @Override
    public String getRoleIdByUser(String userId) {
        return abilityMapper.getRoleIdByUser(userId);
    }

    /**
     * 新增角色功能
     *
     * @param roleAbilityDAO
     * @author xuehao
     * @createDate 2022/2/11 14:19
     * @retuen int
     */
    @Override
    public void insertRoleAbility(RoleAbilityDAO roleAbilityDAO) {
        abilityMapper.insertRoleAbility(roleAbilityDAO);
    }

    /**
     * 查询功能详情
     *
     * @param abilityId
     * @author xuehao
     * @createDate 2022/2/11 15:10
     * @retuen AbilityDetailVO
     */
    @Override
    public AbilityDetailVO getAbilityDetail(String abilityId) {
        return abilityMapper.getAbilityDetail(abilityId);
    }

    /**
     * 编辑功能
     *
     * @param abilityDTO
     * @author xuehao
     * @createDate 2022/2/11 16:52
     * @retuen int
     */
    @Override
    public int updateAbility(AbilityDTO abilityDTO) {
        return abilityMapper.updateAbility(abilityDTO);
    }

    /**
     * 查一级菜单id
     *
     * @param menuId
     * @author xuehao
     * @createDate 2022/2/11 18:03
     * @retuen String
     */
    @Override
    public String getParentMenuId(String menuId) {
        return abilityMapper.getParentMenuId(menuId);
    }
}
